﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Finance.UI.Controllers;
using Finance.Bll;
using Finance.IBll;
using Finance.Entity;

namespace Finance.UI.Areas.FinanceManager.Controllers
{
    public class BillController : AreaBaseController
    {
        //
        // GET: /FinanceManager/Finance/
        IBillTypeBll billTypeBll = new BillTypeBll();
        IBankCardBll bankCardBll = new BankCardBll();
        IBillBll billBll = new BillBll();
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Save(int bankCardId, int typeId, decimal amount, string remarks, int id = 0)
        {
            var userName = this.User.Identity.Name.ToLower();
            bool success = billBll.Save(bankCardId, typeId, amount, remarks, userName, id);
            return Json(new { success=true});
        }

        public ActionResult List(int? bankCardId, DateTime? beginDate, DateTime? endDate, int pageSize = 20, int pageIndex = 1)
        {
            var total=0;
            IEnumerable<ViewAccountsEntity> data = billBll.List(bankCardId, beginDate, endDate, pageIndex, pageSize, out total);
           return Json(new { success=true,data,total});
        }

        public ActionResult ListType()
        {
            var data = billTypeBll.List();
            return Json(new { success = true, data });
        }

        public ActionResult ListBankCard()
        {
            var data = bankCardBll.List();
            return Json(new { success = true, data });
        }
    }
}
